# Contributor: Mark Riedesel <mark@klowner.com>
# Maintainer: Mark Riedesel <mark@klowner.com>
pkgname=opencolorio
pkgver=1.1.1
pkgrel=2
pkgdesc="A color management framework for visual effects and animation"
url="https://opencolorio.org"
arch="all"
license="BSD-3-Clause AND GPL-2.0-or-later"
makedepends="boost-dev cmake freeglut-dev glew-dev lcms2-dev python3-dev
	tinyxml-dev yaml-cpp-dev"
subpackages="py3-$pkgname:py3 $pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/imageworks/OpenColorIO/archive/v$pkgver.tar.gz
	ocio-1.1.0-yamlcpp060.patch
	gcc9.patch
	"
builddir="$srcdir/OpenColorIO-$pkgver"

build() {
	local use_ss2
	# Just to be sure we're using Alpine packages.
	rm -f ext/lcms* ext/tinyxml* ext/yaml*

	case "$CARCH" in
		x86_64) use_sse2=TRUE ;;
		*) use_sse2=FALSE ;;
	esac

	mkdir build
	cd build

	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DOCIO_BUILD_TRUELIGHT=OFF \
		-DOCIO_BUILD_NUKE=OFF \
		-DOCIO_BUILD_SHARED=ON \
		-DOCIO_BUILD_STATIC=OFF \
		-DOCIO_USE_SSE="$use_sse2" \
		-DPYTHON=/usr/bin/python3 \
		-DUSE_EXTERNAL_YAML=TRUE \
		-DUSE_EXTERNAL_TINYXML=TRUE \
		-DUSE_EXTERNAL_LCMS=TRUE \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-error=cast-function-type"
	make
}

package() {
	cd "$builddir"/build
	make DESTDIR="$pkgdir" install
}

tools() {
	pkgdesc="OpenColorIO color management framework tools"

	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr
}

py3() {
	pkgdesc="Python3 bindings for OpenColorIO color management framework"
	depends="python3"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib
}

sha512sums="bed722f9ddce1887d28aacef2882debccd7c3f3c0c708d2723fea58a097de9f02721af9e85453e089ffda5406aef593ab6536c6886307823c132aa787e492e33  opencolorio-1.1.1.tar.gz
ef4b0e880c587fcd004865fd938e7f1fb1bbb933abf1ccf352260ebe3a50145664e27b9f1119b72ced99afe4d19b49b0b6c249dd95faaec9c1332ffc44bc9811  ocio-1.1.0-yamlcpp060.patch
b2be3e01d87b3b69fafdd5eff7adc99dd1f222184aaf338956aed5438f43960558423902ec544614cf0677a48849f0f88cd5c74f8dd5a06e20a91aa72a574883  gcc9.patch"
